<template>
  <view class="container">
    <allScroll :listData="listData" :loading="loading" :goodScroll="goodScroll">
      <template v-slot:default="slotProps">
        <view class="order-item" @click="toDetail(slotProps.data)">
          <image class="order-image" :src="imgurl + slotProps.data.ebMerActivityIcon"></image>
          <view class="order-info">
            <view class="order-title">{{ slotProps.data.ebMerActivityTicketName }}</view>
            <view class="order-subtitle">{{ slotProps.data.ebMerActivityName }}</view>
            <view class="order-time">核销时间：{{ slotProps.data.verificationTime }}</view>
          </view>
        </view>
      </template>
    </allScroll>
  </view>
</template>

<script>
import allScroll from "@/components/scroll/index.vue";
import { reconciledList } from "../../utils/merorder/mer";
export default {
  components: {
    allScroll,
  },
  data() {
    return {
      listData: [], // 存储数据的数组
      loading: false,
      /** 数据是否显示完全 */
      goodScroll: true,
      imgurl: uni.getStorageSync("imgurl"),
      /** 分页数据 */
      params: {
        page: 1, // 当前页码
        limit: 10, // 每页数据量
      },
    };
  },
  onLoad() {
    this.reconciledList();
  },
  reachBottom() {
    // 滚动加载更多
    this.reconciledList();
  },
  methods: {
    reconciledList() {
      console.log(10);
      this.loading = true;
      if (!this.goodScroll) return;
      reconciledList({
        ...this.params,
        orderType: 2,
        status: 2,
        verificationMerId: uni.getStorageSync("merId"),
      }).then((res) => {
        let lists = [];
        if (res.data && res.data.list) {
          lists = res.data.list;
        }
        this.loading = false;
        this.goodScroll = lists.length >= this.params.limit;
        this.params.page++;
        this.listData = this.listData.concat(lists);
      });
    },
    //跳转到核销界面
    toDetail(data) {
      let ticketCode = data.ebMerActivityTicketRecordList[0].ticketCode;
      uni.navigateTo({
        url: "/pages_sh/orderCode/redempt?ticketCode=" + ticketCode,
      });
    },
  },
};
</script>

<style lang="less" scoped>
.container {
  padding: 20px;
  background-color: #f5f5f5;
}

.order-item {
  display: flex;
  align-items: center;
  padding: 15px;
  margin-bottom: 10px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.3s ease;

  &:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }
}

.order-image {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  margin-right: 15px;
}

.order-info {
  flex: 1;
}

.order-title {
  font-size: 16px;
  font-weight: bold;
  color: #333;
  margin-bottom: 5px;
}

.order-subtitle {
  font-size: 14px;
  color: #666;
  margin-bottom: 5px;
}

.order-time {
  font-size: 12px;
  color: #999;
}
</style>
